// pages/index/pinche/index.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    tabIndex: 0,
    tabClass: ['H-theme-border-color9 H-theme-font-color9','',''],
    fenxiangzhuan: {
      show: false,
      width: '118rpx;',
      height: '100rpx;',
      bottom: '212rpx;',
      top: '16rpx'
    }
  },
  backto: function (e) {
    wx.navigateBack({})
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.showLoading({
      title: '加载中…',
    })
    let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
    this.setData({
      token: extConfig.appid
    })
    wx.request({
      url: 'https://www.58zltc.com/api.php/Pinche?token=' + this.data.token,
      success: res => {
        this.setData({
          list: res.data
        })
        wx.hideLoading()
      }
    })
  },
  setTab: function(e){
    var index = e.target.dataset.id;
    var tab = ['','',''];
    tab[index] = 'H-theme-border-color9 H-theme-font-color9';
    this.setData({
      tabIndex: index,
      tabClass: tab
    })
    console.log(index);
  },
  bindCall: function (e) {
    var tel = e.target.dataset.tel;
    console.log(tel);
    wx.makePhoneCall({
      phoneNumber: tel
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    app.confirmCommission()
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let that = this;
    return {
      title: '顺风车',
      path: 'pages/index/pinche/index' + '?fenxiang=' + app.globalData.openid + '&fWid=' + that.data.list[0].wid,
      success: function (res) {
        var a = that.data.fenxiangzhuan
        a.show = false
        that.setData({
          fenxiangzhuan: a
        })
        // 转发成功
        wx.showToast({
          title: '转发成功！',
        })
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  changeFXZ: function () {
    var that = this;
    var a = that.data.fenxiangzhuan
    a.show ? a.show = false : a.show = true
    that.setData({
      fenxiangzhuan: a
    })
  }
})